function request(args={}){
	// 处理参数
	let url = args.url || '',
		method = args.method || 'GET',
		data = args.data || {},
		timeout = args.timeout || 10000,
		success = args.success || (()=>{}),
		fail = args.fail || (()=>{})
	
	this.$util.loading.open()
	uni.request({
		url: this.$api.baseUrl + url,
		method,
		data,
		timeout,
		success: res=>{
			this.$util.loading.close()
			let { code, msg, data } = res.data
			
			// 判断请求状态
			switch(code){
				case 0:		// 成功
					success(data)
					break
				default:	// 失败
					fail()
					this.$util.toast(msg || res.data)
					break
			}
		},
		fail: err=>{
			this.$util.loading.close()
			this.$util.toast('数据加载失败')
			fail(err)
		}
	})
}
export default request